package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.LocalDNSAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <Description> <br>
 *
 * @author cheng.leizhen01<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2021年3月16日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler <br>
 */
@Service
@AttrHandler(LocalDNSAttrHandler.class)
public class LocalDNSAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    /**
     *域名  当是否域名解析为‘是’时，显示且必填
     * 掩码  当是否域名解析为‘是’时，显示且必填
     * AS NUMBER  当是否域名解析为‘是’时，显示且必填
     */

    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        if (Objects.isNull(attr) || KiteStringUtils.isEmpty(attr.getValue())) {
            return;
        }
        //域名 200001561
        //掩码 200001562
        // AS NUMBER 200001563
        if(KiteStringUtils.equalsAny(attr.getValue(),"1_0000106" )){
            LocalAttrHelper.showAndNonnull(inst, "200001561", "200001562", "200001563");
        } else {
            LocalAttrHelper.hideAndNullable(inst, "200001561", "200001562", "200001563");
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

}
